#ifndef _asce_inc_render_common
#define _asce_inc_render_common

#include <vector>
#include <string>
#include <cstring>
#include <iostream>
#include <GL/gl.h>   // OpenGL itself.
#include <GL/glu.h>  // GLU support library.
#include <GL/glut.h> // GLUT support library.
#include <GL/glx.h>  // Header file fot the glx libraries.

#include <stdio.h>      // Header file for standard file i/o.
#include <stdlib.h>     // Header file for malloc/free.
#include <unistd.h>     // needed to sleep.

#define PICKING_MODE_OFF	1
#define PICKING_MODE_ON		2

#define BUFSIZE			512


struct		Image 
{
  unsigned long sizeX;
  unsigned long sizeY;
  char		*data;
};
typedef struct Image Image;

class		RenderCommon
{
public:

  RenderCommon();
  ~RenderCommon();

  void		render();
  void		setupRc();    
  void		changeSize(GLsizei w, GLsizei h);

  void		normalKeyEvent(unsigned char key, int x, int y);
  void		specialKeyEvent(int key, int x, int y);
  void		mouseEvent(int button, int state, int x, int y);
  void		mousePassiveMotion(int x, int y);

protected:

  int		windowH;
  int		windowW;
  
  // define picking mode state
  int		pickingMode;
  int		xToPick;
  int		yToPick;
  GLuint	selectBuf[BUFSIZE];

  void		printText(int x, int y, char *s, float r, float g, float b);
  void		printText(int x, int y, char *s, 
			  float r, float g , float b
			  , void *font, int lineSpace);
  // draw a counter clockwise square
  void		drawSquareCCW(float xLco, float yLco
			      , float width, float heigh
			      , float depth
			      , float r, float g, float b
			      , float alpha ,int name);

  void		startPicking(int x, int y);
  int		stopPicking(int level);
  void		processHits(GLint hits, GLuint buffer[]);
  

};

#endif
